package com.syyo.gulimall.coupon.controller;

//import org.springframework.security.access.prepost.PreAuthorize;

import com.syyo.common.domain.ResultVo;
import com.syyo.common.utils.ResultUtils;
import com.syyo.gulimall.coupon.domain.req.SeckillSkuNoticeReq;
import com.syyo.gulimall.coupon.service.SeckillSkuNoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 秒杀商品通知订阅
 *
 * @author syyo
 * @email syyo@gmail.com
 * @date 2021-01-20 09:35:54
 */
@RestController
@RequestMapping("/coupon/seckillskunotice")
public class SeckillSkuNoticeController {

    @Autowired
    private SeckillSkuNoticeService seckillSkuNoticeService;

    /**
     * 新增
     */
    @PostMapping
    // @PreAuthorize("@syyo.check('system:seckillskunotice:add')")
    public ResultVo add(@RequestBody SeckillSkuNoticeReq req) {
        return ResultUtils.ok(seckillSkuNoticeService.add(req));
    }

    /**
     * 删除
     */
    @DeleteMapping("/{id}")
    // @PreAuthorize("@syyo.check('system:seckillskunotice:del')")
    public ResultVo del(@PathVariable("id") Integer id) {
        return ResultUtils.ok(seckillSkuNoticeService.del(id));
    }

    /**
     * 修改
     */
    @PutMapping
    // @PreAuthorize("@syyo.check('system:seckillskunotice:edit')")
    public ResultVo edit(@RequestBody SeckillSkuNoticeReq req) {
        return ResultUtils.ok(seckillSkuNoticeService.edit(req));
    }

    /**
     * 信息
     */
    @GetMapping("/{id}")
    public ResultVo findOne(@PathVariable("id") Integer id) {
        return ResultUtils.ok(seckillSkuNoticeService.findOne(id));
    }

    /**
     * 列表
     */
    @GetMapping("/list/{pageNum}/{pageSize}")
    public ResultVo findAll(@PathVariable("pageNum") Integer pageNum,
                            @PathVariable("pageSize") Integer pageSize,
                            SeckillSkuNoticeReq req) {
        return ResultUtils.ok(seckillSkuNoticeService.findAll(pageNum, pageSize, req));
    }

}
